package by.grsu.bso.persistence.util;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class DaoManager {

	public DaoManager() {

	}

	protected static final Connection getConnection() {
		return ConnectionProvider.getConnection();
	}

	protected static final void closeConnection(Connection conn, ResultSet rs, Statement stmt) {
		if (rs != null) {
			try {
				rs.close();
			} catch (Exception ignore) {
			}
		}

		if (stmt != null) {
			try {
				stmt.close();
			} catch (Exception ignore) {
			}
		}
		
		//todo: free connection
		try {
			if (conn != null && !conn.isClosed()) {
				conn.close();
			}
		} catch (SQLException e) {
		}
	}

}
